//
//  TpicDetailViewController.m
//  Slice
//
//  Created by lanou on 16/6/18.
//  Copyright © 2016年 wangjinchao. All rights reserved.
//

#import "TpicDetailViewController.h"

@interface TpicDetailViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, retain) NSTimer *timer;

@end

@implementation TpicDetailViewController

-(NSMutableArray *)dataArray {
    if (_dataArray == nil) {
        _dataArray = [NSMutableArray array];
    }
    return _dataArray;
}


- (void)getData {
    [RequestTool requsetWithType:POST URLString:kTopicDetailListURL paremeter:@{@"contentid":self.contentid} callBack:^(NSData *data, NSError *error) {
        if (data == nil) {
            return ;
        }
        
        NSDictionary *dataDic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves | NSJSONReadingMutableContainers error:nil];
        NSLog(@"%@",dataDic);
        
    }];
}




- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kWidth, kHeight) style:UITableViewStylePlain];
    [self.view addSubview: self.tableView];
    

   self.tableView.tableHeaderView = [[[NSBundle mainBundle] loadNibNamed:@"TopicDetailHeaderView" owner:self options:nil] lastObject];
    
////    第二种方法
//    self.tableView.tableHeaderView = [TopicDetailHeaderView getView];
    
    self.tableView.delegate = self;
    
    self.tableView.dataSource = self;
    
    [self.tableView registerNib:[UINib nibWithNibName:@"TopicDetailTableViewCell" bundle:nil] forCellReuseIdentifier:@"123"];
    
  self.timer = [NSTimer scheduledTimerWithTimeInterval:4 target:self selector:@selector(click) userInfo:nil repeats:YES];
    
    
}

- (void)click {
    [self.timer setFireDate:[NSDate distantFuture]];
    NSLog(@"%f",self.timer.tolerance);
    [self.timer setFireDate:[NSDate dateWithTimeIntervalSinceNow:4]];
}


- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataArray.count;
}

- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 100;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    TopicDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"123" forIndexPath:indexPath];
    cell.commenterNameLable.text = self.dataArray[indexPath.row];
    return cell;
}






@end
